package cn.stacey.elasticsearch.domain;

import java.util.Date;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Document(indexName = "product")
public class Product {
	@Id
	private Integer id;
	//text类型的域会进行分词
	@Field(index = true, analyzer = "ik_smart", store = true, type=FieldType.Text)
	private String name;
	
	@Field(index = false, store = true, type=FieldType.Integer)
	private Integer cid;
	
	//KeyWord不会分词
	@Field(index = true, store = true, type=FieldType.Keyword)
	private String category;
	
	@Field(index = true, store = true, type=FieldType.Double)
	private Double price;
	
	@Field(index =false, store = true, type=FieldType.Long)
	private Long num;
	
	@Field(index = true, analyzer = "ik_smart", store = false, type=FieldType.Text)
	private String description;
	
	@Field(index =false, store = true, type=FieldType.Keyword)
	private String image;
	
	@Field(index =true, store = true, type=FieldType.Date)
	private Date create;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getCid() {
		return cid;
	}
	public void setCid(Integer cid) {
		this.cid = cid;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public Double getPrice() {
		return price;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	public Long getNum() {
		return num;
	}
	public void setNum(Long num) {
		this.num = num;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getImage() {
		return image;
	}
	public void setImage(String image) {
		this.image = image;
	}
	public Date getCreate() {
		return create;
	}
	public void setCreate(Date create) {
		this.create = create;
	}
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Product [id=");
		builder.append(id);
		builder.append(", name=");
		builder.append(name);
		builder.append(", cid=");
		builder.append(cid);
		builder.append(", category=");
		builder.append(category);
		builder.append(", price=");
		builder.append(price);
		builder.append(", num=");
		builder.append(num);
		builder.append(", description=");
		builder.append(description);
		builder.append(", image=");
		builder.append(image);
		builder.append(", create=");
		builder.append(create);
		builder.append("]");
		return builder.toString();
	}
	
	
}
